<template>
  <div class="search">
    <f-form ref="form" :action="api.company" :form-key="this.formItem.companyId" >
      <f-form-item label="密钥"  name="companySecret" dataType="${formField.dataType}"   :value="formItem.companySecret" />
      <f-form-item label="公司代码"  name="companyCode" dataType="${formField.dataType}"   :value="formItem.companyCode" />
      <f-form-item label="联系人"  name="linkMan" dataType="${formField.dataType}"   :value="formItem.linkMan" />
      <f-form-item label="合作状态"  name="companyState" dataType="number"   :value="formItem.companyState" />
      <f-form-item label="地址"  name="address" dataType="${formField.dataType}"   :value="formItem.address" />
      <f-form-item label="公司名称"  name="companyName" dataType="${formField.dataType}"   :value="formItem.companyName" />
      <f-form-item label="公司电话"  name="companyTel" dataType="${formField.dataType}"   :value="formItem.companyTel" />
      <f-form-item label="公司LOGO"  name="companyLogo" dataType="${formField.dataType}"   :value="formItem.companyLogo" />
      <f-form-item label="过期日期"  name="expireDate" dataType="${formField.dataType}"   :value="formItem.expireDate" />
      <f-form-item label=""  name="createDate" dataType="${formField.dataType}"   :value="formItem.createDate" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'companyForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          companyId: '',
          companySecret: '',
          companyCode: '',
          linkMan: '',
          companyState: '',
          address: '',
          companyName: '',
          companyTel: '',
          companyLogo: '',
          expireDate: '',
          createDate: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.companyId) {
          let params={
              companyId:data.companyId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
